package ar.edu.utn.frba.dds.opendesigners.date;

import java.util.Calendar;
import ar.edu.utn.frba.dds.opendesigners.format.*;

public class Date {
	
	private Calendar date;
	
	public Date(Calendar date){
		this.date = date;
	}
	
	public boolean before(Date dateA){
		return this.date.before(dateA.date);
	}
	public int getYear(){
		return this.date.get(this.date.YEAR);
	}
	

	public int getDaysOfYear(){
		return this.date.get(this.date.DAY_OF_YEAR);
	}
	
	public int getMaximumDaysOfYear(){
		return this.date.getMaximum(this.date.DAY_OF_YEAR);
	}
	
	public int getYearDiferenceInDays(Date dateA, Date dateB){
		return Math.abs(dateA.getYear() - dateB.getYear()) * 365;
	}
	
	public int daysBetweenYears(Date dateA, Date dateB){
		return  this.getYearDiferenceInDays(dateA, dateB) + (dateA.getMaximumDaysOfYear() - dateB.getMaximumDaysOfYear());
	}
	
	public int daysBetween(Date dateA, Date dateB){
		return  this.daysBetweenYears(dateA, dateB) + Math.abs(dateA.getDaysOfYear() - dateB.getDaysOfYear());
	}
	
	public int daysBetween(Date dateA){
		return this.daysBetween(this, dateA);
	}
		
	public boolean before(Date dateA, Date dateB) {
		return dateA.before(dateB);
	}
}
